package homework;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class UserTest {
    public static void main(String[] args) throws IOException {
        String name;
        String pwd;
        String nick;
        int age;
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入name：");
        name = scan.nextLine();
        System.out.println("请输入pwd：");
        pwd = scan.nextLine();
        System.out.println("请输入nick：");
        nick = scan.nextLine();
        System.out.println("请输入age：");
        age = scan.nextInt();
        User u = new User(name,pwd,nick,age);
        FileOutputStream fos = new FileOutputStream(u.getName() + ".obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject(u);
        System.out.println("对象序列化完成");
        oos.close();
    }
}
